<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class News extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    public static function boot(){
        // 继承父类
        parent::boot();
        // updating creating saving 这几个方法你自己选择，打印一下$model看看你就知道怎么取出数据了
        static::creating(function ($model) {
            //系统变量  中的  云存储域名
//            $hostUrl= env("ALIYUN_OSS_URL");
            $hostUrl= 'https://fengziheng-1304516760.cos.ap-shanghai.myqcloud.com/';
            $model->images = $hostUrl . $model->images;
        });

        static::updating(function ($model) {
            $hostUrl= 'https://fengziheng-1304516760.cos.ap-shanghai.myqcloud.com/';
            $model->images = $hostUrl . str_replace($hostUrl,"-", $model->images);
        });
    }
    

}
